Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

649
Visualizações
Apache2: Expected </Directory> but saw </VirtualHost>

I recently started an apache2 server on my raspi, working totally fine. Today, I had to restart my server, without ever changing my config files, and for some reason got the following error:

apache2: Syntax error on line 225 of /etc/apache2/apache2.conf: 
Syntax error on line 30 of /etc/apache2/sites-enabled/default-ssl.conf: 
Expected </Directory> but saw </VirtualHost>

Well, I thought, lets track that down:

/etc/apache2/apache2.conf

   [...]

   217  
   218  # Include of directories ignores editors' and dpkg's backup files,
   219  # see README.Debian for details.
   220  
   221  # Include generic snippets of statements
   222  IncludeOptional conf-enabled/*.conf
   223  
   224  # Include the virtual host configurations:
   225  IncludeOptional sites-enabled/*.conf
   226  
   227  # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Nothing wrong with line 255. Actually included by apache itself.

/etc/apache2/sites-enabled/default-ssl.conf

     1  <IfModule mod_ssl.c>
     2      <VirtualHost *:443>
     3  
     4          ServerAdmin myemail@gmail.com
     5          ServerName mydomain.net
     6  
     7          DocumentRoot /var/www/html
     8  
     9          <Directory /var/www/html>
    10              Options Indexes FollowSymLinks
    11              AllowOverride None
    12              Require all granted
    13          </Directory>
    14  
    15          ErrorLog ${APACHE_LOG_DIR}/error.log combined
    16          CustomLog ${APACHE_LOG_DIR}/access.log combined
    17  
    18          SSLEngine on
    19          SSLCertificateFile  /etc/apache2/ssl/mydomain.net.cer
    20          SSLCertificateKeyFile /etc/apache2/ssl/mydomain.net.key
    21          SSLCertificateChainFile /etc/apache2/ssl/mydomain.net.intermediate.cer
    22  
    23          <Directory /var/www/html/Humboldtplan>
    24              AuthType Basic
    25              AuthName "Restricted Content"
    26              AuthUserFile /etc/apache2/.passwords/humboldt
    27              Require valid-user
    28          </Directory>
    29  
    30      </VirtualHost>
    31  </IfModule>

Now I can really not figure out the problem here. I broke my head down on what could be wrong but everything seems right to me. All tags are properly closed, the </VirtualHost> is where it should be. Also, the exact same config worked before, whats the problem so suddenly?

I thought it might be an unrelated problem like memory, so I did all the basic stuff. Updated all the packages, rebooted my raspi, still didn't work, shut it down and unplugged it in order to fix eventual memory issues, still didn't work.

What is wrong here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Well the answer is a disappointing "whitespace" error. Printing out the escaped characters with cat -An [...] gave me the following:

     7  ^I^IDocumentRoot /var/www/html$
     8  $
     9  ^I^I<Directory /var/www/html>$
    10  M-bM-^@M-^K^I^I^IOptions Indexes FollowSymLinks$
    11  M-bM-^@M-^K^I^I^IAllowOverride None$
    12  ^I^I^IRequire all granted$
    13  M-bM-^@M-^K^I^I</Directory>$
    14  $
    15  ^I^I#ErrorLog ${APACHE_LOG_DIR}/error.log$
    16  ^I^I#CustomLog ${APACHE_LOG_DIR}/access.log combined$
    17  $

I have no idea what exactly M-bM-^@M-^K means (other than some form of UTF-8 whitespace characters) nor how they actually ended up in that file (especially as I have, as I said, not edited them while the server was up). But removing those seems to have resolved my problem.

These were especially surprising as they were neither stopping my cursor from hopping from tab to tab, nor formatting the document in any way. I only noticed when trying to comment out the specific lines, as they werent marked blue (as "commented") after i put a hashtag in front of them.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda